<?php

    header('content-type:text/html;charset="utf-8') ;
    
    $host = 'localhost:3306';
    $name = 'root';
    $pwd = 'root';
    $dbname = 'test2';
    $conn = mysqli_connect($host , $name , $pwd , $dbname);

    if(!$conn) {
        die('数据库连接失败');
    }


    $id = $_POST['id'];

    $obj = [] ;
    


    $sql = "select * from goods_list where goods_id = $id";

    $res = mysqli_query($conn , $sql) ;

    $arr = mysqli_fetch_array($res) ;

    $data = [];

    if($arr) {
        $data['id'] = $arr['goods_id'] ;
        $data['name'] = $arr['goods_name'] ;
        $data['title'] = $arr['goods_title'] ;
        $data['des'] = $arr['goods_des'] ;
        $data['img'] = $arr['goods_img'] ;
        $data['price'] = $arr['goods_price'] ;
        $data['mode'] = $arr['goods_mode'] ;


        $obj['status'] = true ;
        $obj['msg'] = '数据请求成功';
        $obj['data'] = $data ;
    } else {
        $obj['status'] = false ;
        $obj['msg'] = '服务器错误';
    }

    echo(json_encode($obj , JSON_UNESCAPED_UNICODE));